<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    /*通过function定义函数(方法)*/
    function add(a, b) {
        return a + b;
    }
    /*直接通过函数名调用对应函数*/
    var sum1 = add(10, 20);
    var sum2 = add(10, 20, 30);
    var sum3 = add(10);
    alert(sum1); //30   10+20
    alert(sum2); //30   10+20,30没有接收
    alert(sum3); //NaN  10+NaN
    var getResult = function (a, b) {
        return a + b;
    }
    var result = getResult(10, 20);
    alert(result);
</script>
</body>
</html>